package com.sali.rbac.repository.impl;

import com.sali.rbac.convert.SysRoleConvertDO2Model;
import com.sali.rbac.mapper.SysRolesMapper;
import com.sali.rbac.model.SysRoleModel;
import com.sali.rbac.orm.SysRolesDO;
import com.sali.rbac.repository.ISysRoleRepository;
import com.sali.repository.commons.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @author: sali
 * @date: 2024/8/11 上午9:19.
 * @version: 1.0
 */
@Service
public class SysRoleRepositoryImpl extends BaseServiceImpl<SysRolesMapper, SysRolesDO> implements ISysRoleRepository {

    @Resource
    private SysRolesMapper sysRolesMapper;

    @Resource
    private SysRoleConvertDO2Model sysRoleConvertDO2Model;

    @Override
    public List<SysRoleModel> findRolesByUserId(Long userId) {
        List<SysRolesDO> roles = sysRolesMapper.findRoles(userId);
        return sysRoleConvertDO2Model.convert(roles);
    }
}
